package com.nicky.kids.Share;

import android.content.Context;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXTextObject;

/**
 * Created by NickZhang on 9/15/13.
 */
public class Weixin {

    private static final String APP_ID = "wx322d42181908128c";
    private IWXAPI api;

    public void regToWx(Context ctx) {
        api = WXAPIFactory.createWXAPI(ctx, APP_ID, true);
        api.registerApp(APP_ID);
    }

    public boolean sendRequest() {
        WXTextObject textObject = new WXTextObject();
        textObject.text = text;

        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = textObject;
        msg.description = text;

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;

        api.sendReq(req);
    }
}
